package blo;

import dao.WordDAO;

public class AddWordBLO {
	private WordDAO wordDAO;
	public AddWordBLO() {
		wordDAO = new WordDAO();
	}
	/**
	 * function addWord to database.
	 * 
	 * @param word the word suggest by user
	 * @param meaning meaning suggest by user
	 * @param from id of from language that chose by user
	 * @param to id of to language that chose by user
	 * @return true if add to database sucessful false if can not
	 */
	public boolean addSugestWord(String word, String meaning, int from, int to) {
		boolean result = true;
		DictionariesBLO dictBLO = new DictionariesBLO();
		int dictId = dictBLO.getDictionaryID(from, to);
		if(dictId < 1) return false;
		result = wordDAO.addWord(word, meaning, dictId, 0);
		return result;
	}
	public boolean deleteSuggestWord(int id) {
		boolean result = true;
		result = wordDAO.deleteWord(id);
		return result;
	}
	public boolean updateSuggestWord(int id, String meaning) {
		return wordDAO.updateWord(id, meaning);
	}
	public boolean updateSuggestWord(int id, int status) {
		return wordDAO.updateWord(id, status);
	}
}
